package com.angel.web.app;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.base.JsonEntity;
import com.angel.core.util.JsonUtil;
import com.angel.core.util.JsonUtils;
import com.angel.health.BuzPackages;
import com.angel.health.BuzServicePackages;
import com.angel.health.BuzServicePackagesProject;
import com.angel.health.SysDict;
import com.angel.provider.health.BuzPackagesProvider;
import com.angel.provider.health.BuzServicePackagesProjectProvider;
import com.angel.provider.health.BuzServicePackagesProvider;
import com.angel.provider.sys.sysManagerDictProvider;

/**
 * app服务套餐
 * @author cheng sir
 *
 */
@Controller
@RequestMapping("app/sPackages")
public class AppServicePackagesController {

	@Autowired
	private BuzServicePackagesProvider buzServicePackagesSerivce;
	@Autowired
	private BuzServicePackagesProjectProvider buzServicePackagesProjectProvider;
	@Autowired
	private BuzPackagesProvider bpProvider;
	@Autowired
	private sysManagerDictProvider sdProvider;

	/**
	 * 
	 * @param request
	 * @param buzServicePackages
	 * @return 服务套餐基本信息和服务套餐内容
	 */
	@ResponseBody
	@RequestMapping(value = "index", produces = "application/json; charset=UTF-8")
	public String index(BuzServicePackages buzServicePackages) {
		List<BuzServicePackages> list = buzServicePackagesSerivce.findServicePackagesAll(buzServicePackages);
		return JsonUtils.toJson(new JsonEntity("200", list));
	}
	
	/**
	 * 
	 * @param request
	 * @param buzServicePackages
	 * @return 获取服务套餐基本信息
	 */
	@ResponseBody
	@RequestMapping(value = "getSP", produces = "application/json; charset=UTF-8")
	public String getSP(BuzServicePackages buzServicePackages) {
		buzServicePackages.setEnable(1);
		List<Map<String,Object>> list = buzServicePackagesSerivce.findAll(buzServicePackages);
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
	/**
	 * @param buzPackages
	 * @return 获取体检套餐基本信息
	 */
	@ResponseBody
	@RequestMapping(value = "getHP", produces = "application/json; charset=UTF-8")
	public String getHP(BuzPackages buzPackages){
		buzPackages.setEnable(1);
		List<Map<String,Object>> list = bpProvider.findAll(buzPackages);
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
	/**
	 * @param sysDict
	 * @return 获取增值服务
	 */
	@ResponseBody
	@RequestMapping(value = "getAS", produces = "application/json; charset=UTF-8")
	public String getAS(SysDict sysDict){
		sysDict.setDelFlag("1");
		sysDict.setLabel("addService");
		List<Map<String,Object>> list = sdProvider.findAll(sysDict);
		
		sysDict.setLabel("minutes");
		list.addAll(sdProvider.findAll(sysDict));
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
	
	/**
	 * 
	 * @param buzServicePackages
	 * @return获取服务套餐服务内容
	 */
	@ResponseBody
	@RequestMapping(value = "getSPP", produces = "application/json; charset=UTF-8")
	public String getSPP(BuzServicePackagesProject buzServicePackagesProject) {
		List<BuzServicePackagesProject> list = buzServicePackagesProjectProvider.findSPPAll(buzServicePackagesProject);
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
}
